<script src="assets/jquery/jquery-1.6.2.min.js"></script>
<script src="assets/jquery/jquery-ui-1.8.15.custom.min.js"></script>
<link rel="stylesheet" href="assets/jquery/jqueryCalendar.css">
<script>
jQuery(function() {
	jQuery( "#search2" ).datepicker();
});
</script>
<?php
include"config.php";

$hitung_heru_banned = mysql_query("select * from tbl_heuristik where status = 'banned'");
$hitung_heru_unbanned = mysql_query("select * from tbl_heuristik where status = 'unbanned'");

$no_banned = mysql_num_rows($hitung_heru_banned);
$no_unbanned = mysql_num_rows($hitung_heru_unbanned);
?>
<table width="100%" border="1" cellspacing="5" cellpadding="5" class="tbl_border">
  <tr>
    <td width="66%" bgcolor="#3399FF"><font color="#FF0000" face="Geneva, Arial, Helvetica, sans-serif" size="3"><b>Total Heuristic Banned: <?=$no_banned;?></b></font><br /><font color="#00FF00" face="Geneva, Arial, Helvetica, sans-serif" size="3"><b>Total Heuristic Unbanned: <?=$no_unbanned;?></b></font></td>
    <td width="34%" align="center" bgcolor="#3399FF"><a href="index.php?page=add_heuristik"><img src="assets/image/add_btn.png" width="50" height="51" alt="Add" /></a></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#3399FF"><form action="index.php?page=heuristik_filter&amp;&amp;pencarian" method="post" name="form1" id="form1">
      Filter by Code
      <input type="text" name="search" id="search" />
          <input type="submit" name="button" id="button" value="Search" />
    </form>
	<form action="index.php?page=heuristik_filter&amp;&amp;pencariandetail" method="post" name="form1" id="form1">
      Filter by Detail
      <input type="text" name="search3" id="search3" />
          <input type="submit" name="button" id="button" value="Search" />
    </form>
	</td>
    <td align="center" bgcolor="#3399FF"><form action="index.php?page=heuristik_filter&amp;&amp;pencarian2" method="post" name="form1" id="form1">
      Filter by Date
      <input type="text" name="search2" id="search2" />
          <input type="submit" name="button2" id="button2" value="Search" />
          <br />
    Format : YYYY-MM-DD
    </form></td>
  </tr>
  <tr>
    <td colspan="2"><table width="100%" border="1" cellspacing="4" cellpadding="4">
      <tr>
        <td>#</td>
        <td><a href="index.php?page=heuristik_filter&&sharingan=code&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>
        ">Code</a></td>
        <td><a href="index.php?page=heuristik_filter&&sharingan=detail&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>">Detail</a></td>
        <td><a href="index.php?page=heuristik_filter&&sharingan=status&&opsi=<?php if($_GET['opsi'] == 'asc'){ echo"desc"; }elseif($_GET['opsi'] == 'desc'){ echo"asc"; }else{ echo"asc"; } ?>">Status</a></td>
		<td>Date</td>
        <td><a href="index.php?page=weapon">Config</a></td>
      </tr><?php
if(isset($_GET['pencarian'])){
	$search = $_POST['search'];
	$search = trim($search, ' ');
	$search = trim($search, '\t');
	
	$kueri = mysql_query("select * from tbl_heuristik where code LIKE '%$search%'");
}elseif(isset($_GET['pencarian2'])){
	$search2 = $_POST['search2'];
	$kueri = mysql_query("select * from tbl_heuristik where date = '$search2'");
}elseif(isset($_GET['pencariandetail'])){
	$search3 = $_POST['search3'];
	$kueri = mysql_query("select * from tbl_heuristik where detail LIKE '%$search3%'");
}else{
	$sharingan = $_GET['sharingan'];
	$opsi = $_GET['opsi'];
	$kueri = mysql_query("select * from tbl_heuristik ORDER BY $sharingan $opsi");
}
$kueri_row = mysql_num_rows($kueri);
//echo $kueri_row;
if($kueri_row == 0){
?>
	<tr>
        <td>-</td>
		<td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
        <td>-</td>
      </tr>
<?php
}else{
	$no=0;
	while($data = mysql_fetch_array($kueri))
	{
		$no++;
		if($no%2){
			$pelangi = "class=\"ganjil\"";	
		}else{
			$pelangi = "class=\"genap\"";	
		}
	?>
		<tr <?=$pelangi;?>>
		  <td align="center"><?=$no;?></td>
		  <td align="center"><font color="#FFFFFF"><?=$data['code'];?></font></td>
		  <td align="center"><font color="#FFFFFF"><?=$data['detail'];?></font></td>
		  <td align="center">
		  <?php
		  if($data['status'] == "banned"){
			echo "<font color=#FF0000>Banned</font>";  
		  }elseif($data['status'] == "unbanned"){
			echo "<font color=#003300>Unbanned</font>";
		  }else{
			echo"ERROR";  
		  }	
		  ?>		  </td>
		  <td align="center"><font color="#FFFFFF"><?=$data['date'];?></font></td>
		  <td align="center"><a href="index.php?page=edit_heuristik&&id=<?=$data['id_heuristik'];?>">Edit</a><br /><a href="delete_heuristik.php?id=<?=$data['id_heuristik']; ?>">Delete</a></td>
		</tr>
		<?php
	}
}
	?>
    </table></td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
